<template>
  <view class="root" @touchstart="hideKeyboard">
    <!-- 带返回按钮，右侧显示搜索按钮 -->
    <!-- <acme-app-bar v-model="keywords" right-text="搜索" @rightClick="rightClick" search></acme-app-bar> -->
    
    <!-- 不带返回按钮，右侧显示取消按钮 -->
    <acme-app-bar class="app-bar" v-model="keywords" right-text="取消" :isBack="false" @rightClick="back" search></acme-app-bar>
    
    <view class="history" v-if="historyList.length">
      <view class="title">
        <text>历史记录</text>
        <view class="iconfont reset" @click="remove">&#xe8b9;</view>
      </view>
      <view class="list">
        <view class="offset">
          <view v-for="(item, index) in historyList" :key="index">{{item}}</view>
        </view>
      </view>
    </view>
    
    <view class="find">
      <view class="title">
        <text>搜索发现</text>
      </view>
      <view class="list">
        <view v-for="(item, index) in findList" :key="index">{{item}}</view>
      </view>
    </view>
    
    <acme-dialog v-model="showDialog" type="confirm" title="确认删除全部历史记录？" />
  </view>
</template>

<script>
  import AcmeSearchBar from '@/components/acme-design/search-bar/index.vue'
  import AcmeDialog from '@/components/acme-design/dialog/index.vue'
  
  export default {
    components: {
      AcmeSearchBar,
      AcmeDialog
    },
    data() {
      return {
        keywords: '',
        historyList: ['创意公元', '用户体验研究', '机器学习', '设计师', '用户研究', '人机互动', '交互', '应用场景', '算法'],
        showDialog: false,
        findList: ['设计LOGO', '儿童科学小实验', '扫地机器人', '最爱开箱图', '球赛观后感', '数码的事我懂', '冬季护理指南', '万物皆可棋盘格']
      }
    },
    methods: {
      rightClick() {
        
      },
      back() {
        uni.navigateBack()
      },
      remove() {
        this.showDialog = true
      },
      hideKeyboard() {
        uni.hideKeyboard()
      },
    }
  }
</script>

<style lang="scss">
  page {
    background-color: #fff;
  }
</style>

<style lang="scss" scoped>
  .root {
    min-height: calc(100vh - 230upx);
    padding: 0 30upx;
    box-sizing: border-box;
    overflow: hidden;
    
    .app-bar {
      /deep/ .acme-search-bar {
        padding: 0 0 0 24upx;
      }
    }
    
    .title {
      margin-top: 40upx;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: space-between;
      
      text {
        color: #333;
        font-size: 32upx;
        font-weight: bold;
      }
      
      .reset {
        padding: 0 24upx;
        margin-right: -24upx;
      }
    }
    
    .history {
      .list {
        margin-top: 45upx;
        max-height: 220upx;
        overflow: hidden;
        
        .offset {
          width: calc(100% + 20upx);
          display: flex;
          flex-wrap: wrap;
          
          > view {
            height: 55upx;
            line-height: 55upx;
            padding: 0 22upx;
            border-radius: 30upx;
            // border: 1px solid #eee;
            margin: 0 20upx 20upx 0;
            color: #333;
            font-size: 26upx;
            position: relative;
            
            &::after {
              content: '';
              position: absolute;
              left: -50%;
              right: -50%;
              top: -50%;
              bottom: -50%;
              margin: auto;
              border-radius: 55upx;
              border: 1px solid #E5E4E5;
              transform: scale(0.5);
              transform-origin: 50% 50% 0;
            }
          }
        }
      }
    }
    
    .find {
      .list {
        margin-top: 35upx;
        display: flex;
        flex-wrap: wrap;
        padding: 0 5upx;
        box-sizing: border-box;
        
        > view {
          width: calc(50% - 25upx);
          box-sizing: border-box;
          padding: 10upx 0;
          margin-bottom: 15upx;
          line-height: 1;
          color: #333;
          font-size: 28upx;
          text-overflow: ellipsis;
          overflow: hidden;
          white-space: nowrap;
          margin-right: 25upx;
        }
      }
    }
  }
</style>
